package common.checkdatagrid
{
	import flash.events.Event;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.controls.DataGrid;

	public class CheckDataGrid extends DataGrid   
	{   
		protected var arrColl:ArrayCollection = null;  //保存被选中的信息   
		
		public function CheckDataGrid()   
		{   
			super();   
			arrColl = new ArrayCollection();   
		}   
		
		//方法名不该取这个的   
		public function get listRendererArray():Array{     
			return listItems;   
		}   
		
		//add   
		public function addToSelected(item:Object):void{   
			
			if(arrColl.getItemIndex(item)<0)   
			{   
				arrColl.addItem(item);   
			}   
		}   
		
		//del   
		public function delFromSelected(item:Object):void{   
			
			if(arrColl.getItemIndex(item)>-1)   
			{   
				arrColl.removeItemAt(arrColl.getItemIndex(item));   
			} 
		}   
		
		//isIn   
		public function isInSelected(item:Object):Boolean{   
			
			if(arrColl.getItemIndex(item)<0)   
			{   
				return false;   
			}   
			else  
			{   
				return true;   
			}   
		}   
		
		public function getSelected():ArrayCollection{   
			return arrColl;   
		}
		public function clear():void{
			if(listItems.length>0)   
			{   
				for(var i:Number=0; i<listItems.length; i++)   
				{   
					if(listItems[i].length>0)   
					{   
						
							listItems[i][0].selected = false;   
							listItems[i][0].dispatchEvent(new Event(Event.CHANGE));   
						  
					}   
				}   
			}   
			arrColl = new ArrayCollection();
			
		}
	}   

}